#include <stdio.h>
#include <string.h>


/**
检查编译器是否支持C11
*/
void detectSupportC11(){
	#if defined __STDC_LIB_EXT1__
	printf("Optional functions are defined.\n")
	#else
	printf("Optional functions are not defined.\n");
	#endif 
}


int main(void){
	//detectSupportC11(); 

	/*使用C11的函数来复制
	char source[] = "Only the mediocre are always at their best.";
	char destination[50];
	if(strcpy(destination,sizeof(destination),source))
		printf("An error occurred copying the string\n");

	printf("%s\n", destination);
	*/

	/**搜索字符
	char str[] = "The quick brown fox";
	char ch = 'q';
	char *pGot_char = NULL;
	pGot_char = strchr(str,ch);
	if(pGot_char)
		printf("Character found was '%c'.\n",*pGot_char);
	*/


	/**搜索字符串
	*/

	char str1[] = "This string contains the holy grail.";
	char str2[] = "the holy grail";
	char str3[] = "the holy grill";

	//Search str1 for the occurence of str2
	if(strstr(str1,str2))
		printf("\"%s\" was found in \"%s\"\n", str2,str1);
	else
		printf("\n\"%s\" was found\n", str2);

	//Search str1 for the occurence of str3
	if(!strstr(str1,str3))
		printf("\n\"%s\" was not found\n", str3);
	else
		printf("We shouldn't get to here!\n");

	return 0;
}